docker compose
Compose of one of features of Docker
Compose specification | Docker Documentation
compose は v2 になっている。docker-compose コマンドと docker compose コマンドはほとんど同じオプションをサポートする。新しくはじめるなら、docker compose を使う
Compose V2 integrates compose functions into the Docker platform, continuing to support most of the previous docker-compose features and flags.
Announcing Compose V2 General Availability | Docker
how to install compose plugin
Install the Compose plugin
volume
Compose specification | Docker Documentation
Docker Volume
Services top-level element
code:shell
<volume>:<container path>
<volume> がパスの時は bind でそうでない場合は volume 名として扱われる
bind を使う時は書き方に注意が必要
Bind mounts | Docker Docs
port は string として書くことが推奨される
Compose file version 3 reference | Docker Documentation
Networking in Compose | Docker Documentation
ports は <host port>:<container port> で指定する
host port は docker の外からアクセスする場合
別の container からのアクセスする場合は <service name>:<container port> でアクセスできる
たぶん同じネットワークにいる場合のみ
明示的に network を指定しない場合は、default network にすべてのサービスが入っているので上の形式で呼び出すことが可能
マニュアルで network 設定している場合は同じネットワークに入っているサービスしか呼び出せない?
呼び出す場合でも形式は <service name>:<container port>
code:shll
ports:
- "3000:8080"
Project name
Use -p to specify a project name
Version and name top-level elements | Docker Docs
After updating compose file, we need to rebuild image to reflect configuration
$ docker compose up --build
docker compose up | Docker Docs